#!/bin/bash

## List all unread document files (no bib or metadata) in citeulike repo
##

repo=/home/pepe/files/lispler/citeulike/

## track changes to last list
## compare to what is left on device, mark differences as read
lastlist=/home/pepe/files/lispler/lastlist

# TODO: first, check what was deleted and set new prios accordingly

for entry in $(find "$repo" -maxdepth 1 -type d |sed s/".*\/"//); do
  [ $(cat "$repo/$entry/.priority") -ne 0 ] && entries="$entries
$prio $entry"
done

# sort by priority
entries="$(echo "$entries"|sort -rn|cut -d " " -f 2)"

# print docs
for entry in $entries; do
  echo "$(find "$repo/$entry/" -type f |grep -v ".priority\|[0-9]*.bib$")"
done
